import { ResPage } from "@/api/interface/index";
import { Report } from "@/api/interface/reportManagement";
import { BASE, BASENO } from "@/api/config/servicePort";
import http from "@/api";
import moment from "moment";
/**
 * @name 公告管理模块
 */
// 获取公告户列表
export const getReportList = (params?: object) => {
  if (params && params["created_at"] && params["created_at"].length === 2) {
    params["created_at_after"] = moment(params["created_at"][0]).format("YYYY-MM-DD HH:mm:ss");
    params["created_at_before"] = moment(params["created_at"][1]).format("YYYY-MM-DD HH:mm:ss");
    delete params["created_at"];
  }
  return http.get<ResPage<Report.ResReportList>>(BASE + `/report/`, params); // 正常 post json 请求  ==>  application/json
};

// 删除公告
export const ReportTerminate = (params: { ids: any[] }) => {
  return http.delete(BASE + `/report/${params.ids[0]}/`); // 正常 post json 请求  ==>  application/json
};

// 生成报告
export const getReporting = (params?) => {
  return http.post(BASENO + `/ops/api/report/reporting/`, params);
};

// 修改报告
export const modifyReport = (id, params) => {
  return http.put(BASE + `/report/${id}/`, params);
};

// 上传文件
export const uploadPdfApi = params => {
  return http.post(BASE + `/file/`, params);
};

// 下载文件
export const downloadPdfApi = params => {
  return http.get(BASE + `/file/${params}/download/`);
};
// 报告详情
export const reportView = id => {
  return http.get<Report.ResReportList>(BASE + `/report/${id}/`);
};
